<?
/// --- AKCIÓ-VÉGREHAJTÁS ---

// FELHASZNÁLÓI AKCIÓK
switch($_GET['act']){
	case "sell":
		$cust = new DataRowManager('customers', $_GET['id']);
		if($cust->own()){
		start_transaction();
			$animal = new DataRowManager('animals', $cust->get('animal'));
			$userdata->increaseMoney($cust->get('money'));
			$animal->destroy();
			$cust->destroy();
		end_transaction();
		}
	
}





///  --- OLDAL-ADATOK ELŐKÉSZÍTÉSE ---

// CONTENTS
	//vasarlok
	$a_list = new DataListManager('customers', 'userid='.$_SESSION['userid'].'');
		$i=0;
		while($currcust = $a_list->next_row()){
			$curranimal = new DataRowManager('animals', $currcust->get('animal'));
			$val =  array();
		
			//row start/end
			if($i % 2 == 0){
				$val['rowstart']='<tr>';
				if($i==$a_list->length-1){ // utsó, de páratlan
					$val['rowend'] = '<td>&nbsp;</td></tr>';
				}
			}
			else{
				$val['rowend']='</tr>';
			}
			
			//id
			$val['id']=$currcust->get('id');
			
			//name
			$val['name']= $curranimal->get('name');
			
		
			
			
			//image
			$val['image']='template/images/'.$curranimal->get('type').$curranimal->get('image').'.jpg';
			
			//happy
			$val['jokedv'] = round(calcHappy($curranimal));
			
			
			
			setContents('allatlista', $val);
			$i++;
		
			
			
			
	
			//customer
			$names = explode(",", $lang->get('vasarlonev'));
			$val['customer'] = $names[$currcust->get('name')-1];
			
			$val['income'] = $currcust->get('money');
			
			setContents('vasarlok', $val);
		}
	

// OUTPUT




?>
